package com.EpidemicPrevention.service;

import com.EpidemicPrevention.mapper.SignMapper;
import com.EpidemicPrevention.pojo.Sign;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SignServiceImpl implements SignService {
    @Autowired
    private SignMapper signMapper;

    @Override

    public JSON saveSign (Sign sign) {
        JSONObject json = new JSONObject();
        int code = 0;
        code = signMapper.saveSign(sign);
        if (code == 1) {
            json.put("code", 1);
            json.put("msg", "保存成功");
        } else {
            json.put("code", 0);
            json.put("msg", "保存失败");
        }
        return json;
    }

    public JSON deleteSign(int s_id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = signMapper.deleteSign(s_id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public List<Sign>  querySign (int page, int limit, String Keyword) {
        return signMapper.querySign(page, limit,null);
    }

}
